#ifndef SCENE_H
#define SCENE_H
#include "node.h"
#include "glm/glm.hpp"
#include <vector>
#include "screen.h"
#include "world.h"

class scene : public node{
    protected:
        glm::vec2 camera_position = glm::vec2(0,0);
        glm::vec2 world_size = glm::vec2(0);
        std::vector<world*> children_world_;
        std::vector<screen*> children_screen_;
        void looplog(node* child);
        bool isPause = false;
    public:
        scene(){};
        ~scene(){};
        virtual void init()override;
        virtual void clean()override;
        virtual void render() override;
        virtual void update(float dt)override;
        virtual bool handleEvents(SDL_Event& event)override;
        void scene::addChild(node* child) override;
        void scene::removeChild(node*  child) override;
        glm::vec2 worldToScreen(const glm::vec2& world_position)const{
            return world_position - camera_position;
        };
        glm::vec2 screenToWorld(const glm::vec2& screen_position)const{
            return screen_position + camera_position;
        }
        void setCameraPosition(const glm::vec2 &camera_position_);
        glm::vec2 getCameraPosition()const{return camera_position;}
        glm::vec2 getWorldSize(){return world_size;}
        void setWorldSize(const glm::vec2 &world_size_){world_size = world_size_;};
        auto& getChildrenWorld(){return children_world_;}
        auto& getChildrenScreen(){return children_screen_;}
        void Pause(){isPause = true;}
        void Resume(){isPause = false;}
        bool getPause(){return isPause;}
        virtual void saveData(const char* filename){};
        virtual void loadData(const char* filename){};
};

#endif